package com.scope.imageFilters;

import org.opencv.imgproc.Imgproc;

/**
 * Created by Samrith on 12/10/13.
 */

public enum AdaptiveType {
    MEAN(Imgproc.ADAPTIVE_THRESH_MEAN_C),
    GAUSSIAN(Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C),
    REVERSE_GAUSSIAN(0 - Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C);

    private final int mValue;
    int getValue() {
        return mValue;
    }

    AdaptiveType(int value) {
        mValue = value;
    }

    @Override
    public String toString() {
        return Integer.toString(mValue);
    }

    public static AdaptiveType fromInteger(int val) {
        switch (val) {
            case Imgproc.ADAPTIVE_THRESH_MEAN_C:
                return MEAN;
            case Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C:
                return GAUSSIAN;
            case 0 - Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C:
                return REVERSE_GAUSSIAN;
            default:
                throw new IllegalArgumentException();
        }
    }

    public static AdaptiveType fromString(String str) {
        try {
            return AdaptiveType.fromInteger(Integer.parseInt(str));
        } catch (Exception e) {
            throw new IllegalArgumentException(str);
        }
    }
}